
import { createStore } from "redux";

const initalState = {
  counter: 100
}

export const increment = (counter) => ({type: "INCREMENT", counter})
export const decreament = counter => ({type: "DECREMENT", counter})

function reducer(state = initalState, action) {
  switch (action.type) {
    case "INCREMENT":
      return { ...state, counter: state.counter + action.counter }
    
    case "DECREMENT":
      return { ...state, counter: state.counter - action.counter}
  
    default:
      return state;
  }
}

const store = createStore(reducer);

export default store;